package org.bcncoding.appengine.droiding.server.dao;

import java.util.List;

import javax.jdo.Query;

import org.bcncoding.appengine.droiding.server.entity.Station;

public class StationDao extends AbstractDao<Station> {

	public StationDao(Class<Station> type) {
		super(type);
	}

	@SuppressWarnings("unchecked")
	public Station getByLocation(String location) {
		Query q = pm.newQuery(type);
	    q.setFilter("location == pLocation");
	    q.declareParameters("String pLocation");
	    List<Station> result = (List<Station>) q.execute(location);
	    if (result.size() != 1)
	    	return null;
	    return result.get(0);
	}
}
